package at.redeye.FrameWork.base.translation;

public class MultiLineInput extends javax.swing.JPanel {

    Runnable saveAction;
    Runnable closeAction;

    /** Creates new form MultiLineInput */
    public MultiLineInput() {
        initComponents();

        JTTrans.setText("");
    }

    public void setText( String text )
    {
        JTOrigin.setText(text);
    }

    public void setTransText( String text )
    {
        JTTrans.setText(text);
    }

    public String getText()
    {
        return JTTrans.getText();
    }

    public void setSaveActionListener( Runnable listener )
    {
        saveAction = listener;
    }

    public void setCloseActionListener( Runnable listener )
    {
        closeAction = listener;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.JButton JBCopy = new javax.swing.JButton();
        javax.swing.JButton jBSave = new javax.swing.JButton();
        javax.swing.JButton jBClose = new javax.swing.JButton();
        javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
        JTOrigin = new javax.swing.JTextArea();
        javax.swing.JScrollPane jScrollPane2 = new javax.swing.JScrollPane();
        JTTrans = new javax.swing.JTextArea();

        JBCopy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/at/redeye/FrameWork/base/resources/icons/2downarrow.png"))); // NOI18N
        JBCopy.setText("Kopieren");
        JBCopy.addActionListener(this::JBCopyActionPerformed);

        jBSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/at/redeye/FrameWork/base/resources/icons/button_ok.gif"))); // NOI18N
        jBSave.setText("Speichern");
        jBSave.addActionListener(this::jBSaveActionPerformed);

        jBClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/at/redeye/FrameWork/base/resources/icons/fileclose.gif"))); // NOI18N
        jBClose.setText("Schließen");
        jBClose.addActionListener(this::jBCloseActionPerformed);

        JTOrigin.setBackground(new java.awt.Color(240, 240, 240));
        JTOrigin.setColumns(20);
        JTOrigin.setEditable(false);
        JTOrigin.setLineWrap(true);
        JTOrigin.setRows(5);
        JTOrigin.setText("alskndc lask lcaks  alskmdclmasxc aö#lsxcmaöxc.,   aölm .-a,s c. ,as., dcöal s-.,asölcm-.,a . ,a.; clma, .-,aö#sl döcl a.-, c:_A, x._C a.x,mcöalsmdölfmcaöskm#pemca :Dmc#öalmc .");
        JTOrigin.setWrapStyleWord(true);
        jScrollPane1.setViewportView(JTOrigin);

        JTTrans.setColumns(20);
        JTTrans.setLineWrap(true);
        JTTrans.setRows(5);
        JTTrans.setText("alskndc lask lcaks  alskmdclmasxc a\nö#lsxcmaöxc.,   aölm .-a,s c. ,as., dcöal s-.\n,asölcm-.,a . ,a.; clma, .-,aö#sl döcl a.-, c:_A, x._C \na.x,mcöalsmdölfmcaös\nkm#pemca :Dmc#öalmc .\n");
        jScrollPane2.setViewportView(JTTrans);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 611, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jBSave)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 351, Short.MAX_VALUE)
                        .addComponent(jBClose))
                    .addComponent(JBCopy, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 611, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 611, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(JBCopy)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBClose)
                    .addComponent(jBSave))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jBSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSaveActionPerformed

        if( saveAction != null )
            saveAction.run();

}//GEN-LAST:event_jBSaveActionPerformed

    private void jBCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCloseActionPerformed
        if( closeAction != null )
            closeAction.run();
}//GEN-LAST:event_jBCloseActionPerformed

    private void JBCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBCopyActionPerformed
        JTTrans.setText(JTOrigin.getText());
    }//GEN-LAST:event_JBCopyActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea JTOrigin;
    private javax.swing.JTextArea JTTrans;
    // End of variables declaration//GEN-END:variables

}
